package com.edfu.core.coursemgt.persistence.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.edfu.core.coursemgt.vo.Consts.CourseOfferingMode;
import com.edfu.core.coursemgt.vo.Consts.CourseOfferingState;
import com.edfu.core.coursemgt.vo.Consts.CourseOfferingVisibility;


@Entity
@Table(name="courseoffering", uniqueConstraints=@UniqueConstraint(columnNames={"code"}))
public class CourseOfferingEntity implements ICourseMgtEntity {
	private long id ;
	private String code;
	private String title ;
	private String description ;
	private String contentDirectory ;
	private Set<CourseOfferingOwnerRelnEntity> owners;
	private CourseOfferingState state;
	private CourseOfferingMode mode;
	private CourseOfferingVisibility visibility;
	private String language;
	private String metadata;
	private float price;
	private boolean free;
	private Set<LessonEntity> lessons;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	
	@Column(columnDefinition="TEXT")
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getContentDirectory() {
		return contentDirectory;
	}
	public void setContentDirectory(String contentDirectory) {
		this.contentDirectory = contentDirectory;
	}
	
	@OneToMany(mappedBy="courseOffering", cascade=CascadeType.ALL)
	public Set<CourseOfferingOwnerRelnEntity> getOwners() {
		return owners;
	}
	public void setOwners(Set<CourseOfferingOwnerRelnEntity> owners) {
		this.owners = owners;
	}
	
	@Enumerated
	public CourseOfferingState getState() {
		return state;
	}
	public void setState(CourseOfferingState state) {
		this.state = state;
	}
	
	@Enumerated
	public CourseOfferingMode getMode() {
		return mode;
	}
	public void setMode(CourseOfferingMode mode) {
		this.mode = mode;
	}
	
	@Enumerated
	public CourseOfferingVisibility getVisibility() {
		return visibility;
	}
	public void setVisibility(CourseOfferingVisibility visibility) {
		this.visibility = visibility;
	}
	public String getLanguage() {
		return language;
	}
	public void setLanguage(String language) {
		this.language = language;
	}
	public String getMetadata() {
		return metadata;
	}
	public void setMetadata(String metadata) {
		this.metadata = metadata;
	}
	public float getPrice() {
		return price;
	}
	public void setPrice(float price) {
		this.price = price;
	}
	public boolean isFree() {
		return free;
	}
	public void setFree(boolean free) {
		this.free = free;
	}
	@OneToMany(mappedBy = "courseOffering", fetch= FetchType.EAGER, cascade=CascadeType.ALL)
	public Set<LessonEntity> getLessons() {
		return lessons;
	}
	public void setLessons(Set<LessonEntity> lessons) {
		this.lessons = lessons;
	}
	
}
